
export const showSpecificCamera = async (cameraLabel) => {
    try {
        // 1. 获取所有媒体设备
        const devices = await navigator.mediaDevices.enumerateDevices()

        // 2. 找到名称匹配的摄像头设备
        const videoDevices = devices.filter(device => device.kind === 'videoinput')
        const targetDevice = videoDevices.find(device => device.label === cameraLabel)

        if (!targetDevice) {
            throw new Error('未找到指定摄像头')
        }

        // 3. 获取该摄像头的视频流
        const stream = await navigator.mediaDevices.getUserMedia({
            video: { 
                deviceId: { exact: targetDevice.deviceId },
                width: {
                    ideal: 1920,
                    min: 640,
                },
                height: {
                    ideal: 1080,
                    min: 480,
                }
             },
        })

        return stream
    } catch (err) {
      
        return Promise.reject(err)
    }
}